home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_concrifle_m.cog < prev    next >
Text File  |  1998-02-25  |  8KB  |  278 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # WEAP_CONCRIFLE.COG
  4. #
  5. # WEAPON 9 Script - Concussion Rifle
  6. #
  7. # The trusty weapon of the Bossk race. It fires a concussive blast with a maximum
  8. # range of 30 meters, from there it creates an explosion that has a spread of about
  9. # 4 meters in diameter.
  10. #
  11. # - Not affected by MagSealed sectors/surfaces.
  12. #
  13. # [YB & CYW] + [RF]
  14. #
  15. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  16. # ========================================================================================
  17.  
  18. symbols
  19.  
  20. model       povModel=conv.3do                   local
  21. model       povModel_m=conv_m.3do                    local
  22. model       weaponMesh=cong.3do                 local
  23.  
  24. keyframe    mountAnim=ConVmnt.key               local
  25. keyframe    dismountAnim=ConVdis.key            local
  26. keyframe    povfireAnim=ConVpst1.key            local
  27. keyframe    holsterAnim=kyhlstr.key             local
  28.  
  29. sound       mountSound=df_rif_ready.wav         local
  30. sound       dismountSound=PutWeaponAway01.wav   local
  31. sound       fireSound=concuss5.wav              local
  32. sound       outSound=concuss1.wav               local
  33. sound            failSound=weapfail.wav                    local
  34.  
  35. flex        fireWait=1.2                        local
  36. flex        powerBoost                          local
  37. flex        autoAimFOV=30                       local
  38. flex        autoAimMaxDist=5                    local
  39. flex        holsterWait                         local
  40.  
  41. int         dummy                               local
  42.  
  43. template    projectile=+concbullet              local
  44. template    projectile3=+concblast2             local
  45. template    projectileB=+swsparks                 local
  46.  
  47. thing       player                              local
  48. int         trackID=-1                          local
  49. int         mode                                local
  50. int         holsterTrack                        local
  51.  
  52. int         selectMode=1                  local
  53.  
  54. message     activated
  55. message     deactivated
  56. message     selected
  57. message     deselected
  58. #message     newplayer
  59. message     autoselect
  60. message     fire
  61. message     timer
  62.  
  63. end
  64.  
  65. # ========================================================================================
  66.  
  67. code
  68.  
  69. fire:
  70.    // Check that the player is still alive.
  71.    if(GetThingHealth(player) <= 0)
  72.    {
  73.       Return;
  74.    }
  75.  
  76.    // Check Ammo - If we are out, autoselect best weapon.
  77.    if(GetInv(player, 12) < 8.0)
  78.    {
  79.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  80.       if(GetAutoSwitch() & 1)
  81.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  82.       Return;
  83.    }
  84.  
  85.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  86.  
  87.    SetPOVShake('0.0 -.03 0.0', '4.0 0.0 0.0', .05, 80.0);
  88.     if (GetInv(player, 93) > 0.0)
  89.     {
  90.         dummy = FireProjectile(player, projectileB, failSound, 18, '0.0 0.0 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
  91.         ChangeInv(player, 12, -4.0);
  92.     }
  93.     else
  94.     {
  95.         if (mode == 0)
  96.         {
  97.             dummy = FireProjectile(player, projectile, fireSound, 18, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
  98.             ChangeInv(player, 12, -8.0);
  99.         }
  100.         else
  101.         {
  102.             dummy = FireProjectile(player, projectile3, fireSound, 18, '0.0 0.0 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
  103.             ChangeInv(player, 12, -4.0);
  104.         }
  105.  
  106.         // Provide a kick backwards
  107.         ApplyForce(player, VectorScale(GetThingLVec(player), -80));
  108.     }
  109.  
  110.    jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  111.  
  112.    powerBoost = GetInv(player, 63);
  113.    ChangeFireRate(player, fireWait/powerBoost);
  114.  
  115.    Return;
  116.  
  117. # ........................................................................................
  118.  
  119. activated:
  120.    player = GetSourceRef();
  121.    mode = GetSenderRef();
  122.  
  123.     if (GetInv(player, 93) > 0.0)
  124.         SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  125.  
  126.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  127.  
  128.    powerBoost = GetInv(player, 63);
  129.    ActivateWeapon( player, fireWait/powerBoost, mode );
  130.  
  131.    Return;
  132.  
  133. # ........................................................................................
  134.  
  135. deactivated:
  136.    player = GetSourceRef();
  137.    mode = GetSenderRef();
  138.  
  139.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  140.    DeactivateWeapon( player, mode );
  141.  
  142.    Return;
  143.  
  144. # ........................................................................................
  145.  
  146. selected:
  147.    player = GetSourceRef();
  148.  
  149.    // Play external mounting animation
  150.    PlayMode(player, 41);
  151.  
  152.    // Setup the meshes and models.
  153.     if (GetInv(player, 67) == 0.0)
  154.         jkSetPOVModel(player, povModel);        // Kyle hand
  155.     else
  156.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  157.    SetArmedMode(player, 1);
  158.    jkSetWeaponMesh(player, weaponMesh);
  159.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  160.  
  161.    // Play mounting sound.
  162.    PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
  163.  
  164.    // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
  165.    // The animation is held at the last frame after it is played.
  166.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  167.    SetMountWait(player, GetKeyLen(mountAnim));
  168.  
  169.    // Clear saber flags, and allow activation of the weapon
  170.    jkClearFlags(player, 0x5);
  171.    SetCurWeapon(player, 9);
  172.  
  173.    // Check Ammo - If we are out, autoselect best weapon.
  174.    if(GetInv(player, 12) < 2.0)
  175.    {
  176.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  177.       if(GetAutoSwitch() & 1)
  178.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  179.    }
  180.  
  181.    Return;
  182.  
  183. # ........................................................................................
  184.  
  185. deselected:
  186.    player = GetSourceRef();
  187.  
  188.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  189.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  190.  
  191.    holsterWait = GetKeyLen(holsterAnim);
  192.    SetMountWait(player, holsterWait);
  193.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  194.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  195.    if (trackID != -1)
  196.    {
  197.       jkStopPOVKey(player, trackID, 0);
  198.       trackID = -1;
  199.    }
  200.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  201.  
  202.    Return;
  203.  
  204. # ........................................................................................
  205.  
  206. //newplayer:
  207. // player = GetSourceRef();
  208. //
  209. // // Make sure that if the player is respawning, the old mount isn't playing anymore.
  210. // if (trackID != -1)
  211. //    jkStopPOVKey(player, trackID, 0);
  212. //
  213. // Return;
  214.  
  215. # ........................................................................................
  216.  
  217. autoselect:
  218.    selectMode = GetSenderRef();
  219.    player = GetSourceRef();
  220.  
  221.    // If the player has the weapon
  222.    if(GetInv(player, 9) != 0.0)
  223.    {
  224.       // If the player has ammo
  225.       if(GetInv(player, 12) >= 8.0)
  226.       {
  227.  
  228.          // query for ammo
  229.          if(selectMode == -1)
  230.          {
  231.             ReturnEx(1000.0);
  232.             Return;
  233.          }
  234.  
  235.          if((selectMode == 0) && !(GetAutoPickup() & 2))
  236.          {
  237.             ReturnEx(1000.0);
  238.             Return;
  239.          }
  240.  
  241.          if((selectMode == 1) && !(GetAutoSwitch() & 2))
  242.          {
  243.             ReturnEx(1000.0);
  244.             Return;
  245.          }
  246.  
  247.          if((selectMode == 2) && !(GetAutoPickup() & 2))
  248.          {
  249.             ReturnEx(1000.0);
  250.             Return;
  251.          }
  252.  
  253.          ReturnEx(-2.0);
  254.          Return;
  255.  
  256.       }
  257.       else
  258.       {
  259.          ReturnEx(-1.0);
  260.       }
  261.    }
  262.    else
  263.    {
  264.       ReturnEx(-1.0);
  265.    }
  266.  
  267.    Return;
  268.  
  269. # ........................................................................................
  270.  
  271. timer:
  272.    StopKey(player, holsterTrack, 0.0);
  273.    Return;
  274.  
  275. end
  276.  
  277.  
  278.